﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace EnvControlLib
{
    /// <summary>
    /// 提示框
    /// </summary>
    public partial class ConfirmWindow : Window
    {
        #region 构造函数

        /// <summary>
        /// 
        /// </summary>
        private ConfirmWindow()
        {
            InitializeComponent();

            // 注册系统事件
            okButton.Click += new RoutedEventHandler(okButton_Click);
            cancelButton.Click += new RoutedEventHandler(cancelButton_Click);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="title">提示内容</param>
        public ConfirmWindow(string title)
            : this()
        {
            this.noticeBlock.Text = title;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="title">提示内容</param>
        /// <param name="isHideCancelButton">隐藏“取消”按钮</param>
        public ConfirmWindow(string title, bool isHideCancelButton)
            : this()
        {
            this.noticeBlock.Text = title;

            if (isHideCancelButton) // 确定隐藏“取消”按钮
                cancelButton.Visibility = Visibility.Collapsed;
        }

        #endregion

        #region 系统事件

        private void okButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

        private void cancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        #endregion

        #region DependencyProperty

        public static readonly DependencyProperty ExtArgProperty =
            DependencyProperty.Register("ExtArg", typeof(Object), typeof(ConfirmWindow), null);
        /// <summary>
        /// 附加属性 Object
        /// </summary>
        public Object ExtArg
        {
            get { return (Object)GetValue(ExtArgProperty); }
            set { SetValue(ExtArgProperty, value); }
        }

        #endregion
    }
}
